In [1]:
# Run the magic command that will plot all figures generated by the pylab package
%pylab inline
In [2]:
# Import UrbanScape again
import UrbanScape.urbanscape as us
In [3]:
# Define the big UrbanScape, size = 20, rent = 100000, randomize = True
my_urbanscape = us.UrbanScape(20, 100000, randomize = True)
In [4]:
# Use the plot_urbanscape function to visualize your big urbanscape
us.plot_urbanscape(my_urbanscape)
Isn't that so much better? Now that we can view much larger UrbanScapes, we can start our deep dive into the the different conditions that the UrbanScape module has to offer.
A key optional argument for us to play with is the gradient argument. This will modify the rent distribution in interesting ways so that we can see how different distributions affect the results of our model. It can take in 5 different string values:
'vertical', 'diagonal', 'random', 'CDB', 'BDquadrants'
In [ ]:
# Create an UrbanScape with these conditions
# size 20, rent 100000, randomize = True
# set gradient to each of the above values and plot the UrbanScape
UrbanScape is an Agent-based Model, so now it's time to introduce you to the key ingredient in this particular model: The Food Providers
. There are only two types of Food Providers
in this model: FastFoodAgent
s and GroceryStoreAgents
. To understand how they affect the UrbanScape, we need to add them to the environment.
In [5]:
# Create an UrbanScape
# size = 20, rent = 100000, randomize = True
# set the create_rule to no_create_rule
my_urbanscape = us.UrbanScape(20, 100000, randomize = True, create_rule = us.no_create_rule)
my_urbanscape.step()
In [6]:
# Decide on the location of FastFoodAgent
location = (9,9)
# Create a fast food agent
fastfood_agent = us.FastFoodAgent(location, my_urbanscape)
In [7]:
# Add it to the UrbanScape
my_urbanscape.add_agent(fastfood_agent)
us.plot_urbanscape(my_urbanscape)
In [8]:
my_urbanscape.step()
us.plot_urbanscape(my_urbanscape)
In [9]:
# Decide on the location of GroceryStoreAgent
location2 = (5,5)
# Create a grocery store agent
grocery_store_agent = us.GroceryStoreAgent(location2, my_urbanscape)
# Add it to the UrbanScape
my_urbanscape.add_agent(grocery_store_agent)
my_urbanscape.step()
# Plot it
us.plot_urbanscape(my_urbanscape)